package com.bilibili.server.controller;

import com.bilibili.model.vo.PageResult;
import com.bilibili.model.vo.VideoVo;
import com.bilibili.server.service.SmallVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author HuangRongFu
 * 2021/11/26 星期五4:50 下午
 */

@RestController
@RequestMapping("/smallVideos")
public class SmallVideoController {

    @Autowired
    private SmallVideoService smallVideoService;


    /**
     * 发布小视频
     *
     * @param videoThumbnail
     * @param videoFile
     * @Return: ResponseEntity
     */
    @PostMapping
    public ResponseEntity uploadVideo(MultipartFile videoThumbnail, MultipartFile videoFile) {

        smallVideoService.uploadVideo(videoThumbnail, videoFile);

        return ResponseEntity.ok(null);
    }


    /**
     * 小视频列表
     *
     * @param page
     * @param pageSize
     * @Return: ResponseEntity
     */
    @GetMapping
    public ResponseEntity findPage(@RequestParam(value = "page", defaultValue = "1") Long page,
                                   @RequestParam(value = "pagesize", defaultValue = "10") Long pageSize) {
        PageResult<VideoVo> pageResult = smallVideoService.findPage(page, pageSize);
        return ResponseEntity.ok(pageResult);
    }

}
